package com.xtayfjpk.zookeeper.test.master_workers.watcher;

import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.Watcher.Event.EventType;

import com.xtayfjpk.zookeeper.test.master_workers.Master;

public class MasterExistsWatcher implements Watcher {
	private Master master;
	
	public MasterExistsWatcher(Master master) {
		this.master = master;
	}
	
	@Override
	public void process(WatchedEvent event) {
		if(event.getType()==EventType.NodeDeleted) {
			assert "/master".equals(event.getPath());
			
			master.runForMaster();
		}

	}

}
